package com.eptok.weixin.util;

import java.util.Date;

import yspay.express.bean.responsemessage.Image;
import yspay.express.bean.responsemessage.ResponseImageMessage;
import yspay.express.bean.responsemessage.ResponseNewsMessage;
import yspay.express.bean.responsemessage.ResponseServerMessage;
import yspay.express.bean.responsemessage.ResponseTextMessage;


public class RespMessageUtil {

	/**
	 * 用户关注时的欢迎语
	 * @return
	 */
	public static ResponseTextMessage getHelloMessage(String fromUserName,String toUserName) {
		
		ResponseTextMessage textMessage = getinit(fromUserName,toUserName);
		
		StringBuffer buffer = new StringBuffer();
		buffer.append("您好，感谢您关注'企业快递',我们竭诚为您打造最便捷的客户端体验!");
		textMessage.setContent(buffer.toString());
		
		return textMessage;
		
	}
	
	
	
	public static ResponseTextMessage getErrorMessage(String fromUserName,String toUserName) {
		
		ResponseTextMessage textMessage = getinit(fromUserName,toUserName);
		
		StringBuffer buffer = new StringBuffer();
		buffer.append("亲！客服已经忙晕了，请稍后再试！");
		
		textMessage.setContent(buffer.toString());
		
		return textMessage;
		
	}
	
	
	
	
	
	public static ResponseTextMessage getinit(String fromUserName,String toUserName) {
		
		ResponseTextMessage textMessage = new ResponseTextMessage();
		//回复一个文本消息
		textMessage.setToUserName(fromUserName);
		textMessage.setFromUserName(toUserName);
		textMessage.setCreateTime(new Date().getTime());
		textMessage.setMsgType(MessageUtil.REQ_MESSAGE_TYPE_TEXT);
		
		return textMessage;
	}
	
public static ResponseNewsMessage getInitNews(String fromUserName,String toUserName) {
		
		ResponseNewsMessage msg = new ResponseNewsMessage();
		//回复一个文本消息
		msg.setToUserName(fromUserName);
		msg.setFromUserName(toUserName);
		msg.setCreateTime(new Date().getTime());
		msg.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);
		
		return msg;
	}

public static ResponseImageMessage getInitImage(String fromUserName,String toUserName) {
	
	ResponseImageMessage msg = new ResponseImageMessage();
	//回复一个文本消息
	msg.setToUserName(fromUserName);
	msg.setFromUserName(toUserName);
	msg.setCreateTime(new Date().getTime());
	msg.setMsgType(MessageUtil.REQ_MESSAGE_TYPE_IMAGE);
	return msg;
}


public static ResponseServerMessage getInitServer(String fromUserName,String toUserName) {
	
	ResponseServerMessage serverMsg = new ResponseServerMessage();
	//回复一个文本消息
	serverMsg.setToUserName(fromUserName);
	serverMsg.setFromUserName(toUserName);
	serverMsg.setCreateTime(new Date().getTime());
	serverMsg.setMsgType(MessageUtil.REQ_MESSAGE_TYPE_SERVER);
	return serverMsg;
}
	
	/**
	 * 产生指定长度的随机数
	 * @param size
	 * @return
	 */
	/*private static String getRandomString(int size){
		String str = "";      
		String charSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/-_=";
		 for( int i = 0; i < size; i++ ) {
		        str += charSet.charAt(new Random().nextInt(charSet.length()));  
		    } 
		 return str;
	}
	*/
	
}
